/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function loadForumInfo(id){
    sendAJAXRequest('../../src/Servlets/ForumServlet.php', displayForumInfo, 'action=showForum&forumID=' + id);
}

function displayForumInfo(jsonObj){
    var output = '';
    if (jsonObj == null){
        output = '<p class="errorMsg"> There is no threads for this forum </p>';
    }
    else {
    output = '<table border="1" class="threadsTable">';
    output += '<tr>';
    output += '<th>';
    output += 'Thread Name';
    output += '</th>';
    output += '<th>';
    output += 'Creation Date';
    output += '</th>';
    output += '<th>';
    output += 'Last Post Date';
    output += '</th>';
    output += '</tr>';

    for (var i = 0; i < jsonObj.length; i++) {
        output += '<tr>';
        output += '<td align="center">';
        output += jsonObj[i].THREAD_NAME;
        output += '</td>';
        output += '<td align="center">';
        output += jsonObj[i].CREATION_DATE;
        output += '</td>';
        output += '<td align="center">';
        output += jsonObj[i].LAST_POST_DATE;
        output += '</td>';
        output += '</tr>';
    }

    output += '</table>';
    }
    document.getElementById("threadsDiv").innerHTML = output;

}

